$("#listTable").on("click",".listBody .yujbtn",function(e){
		var target = $(e.currentTarget);
		var id = target.attr("data-id");
		//alert(id)
		var yucln = e.target.className;
		//alert(yucln) 
		if(yucln == "yujbtn onyuj"){
			$.post('http://www.12301.cc/call/jh_alliance.php',{'action':'change_s','status':'1','id':+id}).done(function(code){
				if(code="200"){
					e.target.className = "yujbtn"; 
				}
			}).error(function(){
				alert('发生错误，无法改变状态');
			});
		}else{
			$.post('http://www.12301.cc/call/jh_alliance.php',{'action':'change_s','status':'0','id':+id}).done(function(code){
				if(code="200"){
				   target.addClass("onyuj");
				} else {
					alert(response);
				}
			}).error(function(){
				alert('发生错误，无法改变状态');
			}); 
    }
	})
	//创建营销活动 
	$("#addChildBtn").on("click",function(e){
			var lid = $("#lid").val();
			window.location.href = "http://www.12301.cc/markteing_create.html?lid="+lid;
			return false;
		})
	$("#listTable").on("click",".listBody .close",function(e){ //删除
			var target = $(e.currentTarget);
			var result = window.confirm("确定要删除此景点吗");
			if(!result) return false;
			var citem = target.parents(".listBody");
			deleteChild(citem.data("id"),citem);
		})

	$("#listTable").on("mouseover",".listBody .numPrice",function(e){
			var target = $(e.currentTarget);
			var id = target.attr("data-id");
			arr=id.split(":");
			//alert("平台"+arr[2])
			var leftq = $(this).offset().left;
			var left_1 = $(".col_1").width();
			var left_2 = $(".col_2").width();
			var left_3 =(leftq/20);
			var left = left_1+left_3;
			$("#alliance_m").css({"display":"block","left":left,"top":$(this).offset().top-180})
			contents="<div class='kuai_t'>"+"<span class='red'>平台:</span>"+"<span class='kuai'>"+arr[0]+"</span>"+"</div>"
					+"<div class='kuai_td'>"+"<span class='redd'>供应商:</span>"+"<span class='kuai_thd'>"+arr[1]+"</span>"+"</div>"
					+"<div class='kuai_th'>"+"<span class='redh'>联盟服务商:</span>"+"<span class='kuai_thh'>"+arr[2]+"</span>"+"</div>"
					+"<div class='kuai_th'>"+"<span class='redh'>省服务商:</span>"+"<span class='kuai_thh'>"+arr[3]+"</span>"+"</div>"
					+"<div class='kuai_th'>"+"<span class='redh'>市服务商:</span>"+"<span class='kuai_thh'>"+arr[4]+"</span>"+"</div>"
					+"<div class='kuai_td'>"+"<span class='redd'>分销商:</span>"+"<span class='kuai_d'>"+arr[5]+"</span>"+"</div>"
					+"<div class='kuai_th'>"+"<span class='redh'>上级分销商:</span>"+"<span class='kuai_thh'>"+arr[6]+"</span>"+"</div>";
			$("#alliance_m").html(contents); 
	}) 
	$("#listTable").on("mouseout",".listBody .numPrice",function(e){
		var target = $(e.currentTarget);
		var id = target.attr("data-id");
		$("#alliance_m").css({"display":"none"});
	})
	
	
/*联盟管理 编辑*/
$("#listTable").on('click', '.all_edit', function(e){
	var target = $(e.currentTarget);
	var did = $(this).attr('data-id');
	var pt = target.attr("data-pt");
	arr=pt.split(":");
	var xx_dname = $(this).attr('data-dname');
	var bh = $("body").height(); 
	var bw = $("body").width();  
	$("#fullbg").css({ height:bh, width:bw, display:"block" });
	$("#dialog").show(); 
	// $("#dialog .xx_dname").html(xx_dname);
	$(".dname_a").val(xx_dname);
	$(".platform").val(arr[0]);
	$("#dialog").on('click', '#sure', function(){
		var dname = $(".dname_a").attr("value");
		var platform = $(".platform").attr("value");
		if(dname==''){
		alert("抱歉联盟名称不能为空");
		return false;
		}
		if(platform<0&&platform>50||platform<0){
		alert("抱歉平台比例不正确");
		return false;
		}
		param = {
			action: 'modify_s',
			id: did,
			dname: dname,
			platform: platform, 
		},	elem = $(this);
		$.post('call/jh_alliance.php',param,function(json_res){ 
				if(json_res.status=='success') {
					alert(json_res.msg);
					closeBg();
					location.reload();
				} else {
					alert(json_res.msg);
				}
			},'json');
	});
});
/*联盟管理 编辑结束*/
/*关闭弹窗*/
function closeBg() { 
    $("#fullbg,#dialog").hide(); 
} 
